import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class WrapWidgetPage extends StatefulWidget {
  @override
  WrapWidgetPageState createState() => new WrapWidgetPageState();
}

class WrapWidgetPageState extends State<WrapWidgetPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Wrap'),
      ),
      body:SingleChildScrollView(
        child:wrapDemo,
      ),
    );
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }
}

Widget get wrapDemo =>
    Wrap(
      direction: Axis.horizontal,
      spacing: 5,
      runSpacing: 3,
      crossAxisAlignment: WrapCrossAlignment.center,
      children:List.generate(18, (index) {
        int w=50+10*index;
        return Container(
          color: Colors.primaries[index],
          height: w.toDouble(),
          width: w.toDouble(),
          child: Text('第$index'),
        );
      }),
    );